package main

import (
	"log"
	"os"
	"runtime/pprof"
	"time"
)

func main() {
	fc, err := os.Create("cpu.pprof")
	if err != nil {
		log.Fatal(err)
	}
	if err := pprof.StartCPUProfile(fc); err != nil {
		log.Fatal(err)
	}
	defer pprof.StopCPUProfile()

	//var wg sync.WaitGroup
	//wg.Add(1)
	//go func() {
	//	batch(2000000)
	//	wg.Done()
	//}()
	//wg.Wait()
	t1 := time.Now()
	BatchGoja1(200000)
	log.Printf("esclaped time=%v\n", time.Since(t1).Seconds())
	//BatchCel(200000)
	fm, err := os.Create("mem.pprof")
	if err != nil {
		log.Fatal(err)
	}
	defer fm.Close()
	if err := pprof.WriteHeapProfile(fm); err != nil {
		log.Fatal(err)
	}
}

func batch(c int) {
	Pbexpr(c)
	Pcelgo(c)
	Pcelgo_startswith(c)
	Pevalfilter(c)
	Pexpr(c)
	Pexpr_startswith(c)
	Pgoja(c)
	Pgovaluate(c)
	Pgval(c)
	Potto(c)
	Pstarlark(c)
}
